package com.jsoft.jsofted.platform.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.diboot.core.binding.annotation.BindField;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsNotNull;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.jsoft.jsofted.framework.entity.TimeEntity;
import com.jsoft.jsofted.framework.entity.TreeEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Id;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * 角色信息表
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Table("sys_role")
@TableName("sys_role")
public class RoleEntity implements TimeEntity, TreeEntity {

    @Id
    @Column
    @TableId(type = IdType.ASSIGN_ID)
    protected Long id;

    @Column(length = 64)
    @IsNotNull
    protected String name;

    @Column
    protected Long parentId;

    @TableField(exist = false)
    @BindField(entity = RoleEntity.class, field = "name", condition = "parent_id=id")
    protected String parentName;

    @Column(length = 20, decimalLength = 6)
    @IsNotNull
    protected BigDecimal sortValue;

    @Column
    @IsNotNull
    protected Timestamp createTime;

    @Column
    @IsNotNull
    protected Timestamp updateTime = new Timestamp(System.currentTimeMillis());

}
